var GameState = {};
GameState.start = function() {};
GameState.start.prototype = {
  preload: function() {
    game.load.image('s_Joypad1', 'assets/Joypad1.png');
    game.load.image('s_Joypad2', 'assets/Joypad2.png');
    game.load.image('s_Joypad3', 'assets/Joypad3.png');
    game.load.image('s_Joypad4', 'assets/Joypad4.png');
    game.load.image('s_AttackO', 'assets/AttackO.png');
    game.load.image('s_Attack', 'assets/Attack.png');
    game.load.image('s_BackGround', 'assets/BackGround.png');
    game.load.atlasXML('hero', 'assets/heros.png', 'assets/heros.xml');
    game.load.atlas('test', 'assets/armature/NewProject0.png', 'assets/armature/NewProject.json');
  },

  create: function() {
    //添加背景
    game.add.sprite(0, 0, 's_BackGround');
    this.joypad = new Joypad();
    this.joypad.init();

    this.attackButton = new AttackButton();

    this.hero = new Hero();
    this.hero.init();

    this.cursors = game.input.keyboard.createCursorKeys();
    this.test();
  },

  test: function() {
    var sp = game.add.sprite(0, 0, 'test');
  },

  update: function() {
    
    if (this.cursors.left.isDown) {
      this.hero.moveLeft();
    } else if (this.cursors.right.isDown) {
      this.hero.moveRight();
    } else {
      this.hero.stand();
    }


    if (this.joypad) {
      this.joypad.update();
    }
  }
}